﻿<ucd:HeaderedDialogWindow x:Class="ReflectionStudio.Components.Dialogs.Database.DependencyDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"                          
             xmlns:local="clr-namespace:ReflectionStudio.Components.Dialogs.Database"
             Height="420" Width="310" Title="Dependencies"
             DialogDescription="Display object's dependencies"
             DialogImage="/ReflectionStudio;component/Resources/Images/32x32/information.png"                          
             ShowInTaskbar="False" ResizeMode="CanResizeWithGrip">
    <Window.Resources>

        <Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="{DynamicResource NormalForegroundBrush}"/>
            <Setter Property="FocusVisualStyle" Value="{DynamicResource TreeViewItemFocusVisual}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="19" Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <ToggleButton x:Name="Expander" Style="{DynamicResource ExpandCollapseToggleStyle}"
                                IsChecked="{Binding Path=IsExpanded,
                                RelativeSource={RelativeSource TemplatedParent}}"
                                ClickMode="Press"/>
                            <Border Name="Bd"
                                  Grid.Column="1"
                                  Background="{TemplateBinding Background}"
                                  BorderBrush="{TemplateBinding BorderBrush}"
                                  BorderThickness="{TemplateBinding BorderThickness}"
                                  Padding="{TemplateBinding Padding}">
                                <StackPanel Orientation="Horizontal">
                                    <ContentPresenter x:Name="PART_Header"
                                          ContentSource="Header"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                                </StackPanel>
                            </Border>
                            <ItemsPresenter x:Name="ItemsHost"
                                  Grid.Row="1"
                                  Grid.Column="1"
                                  Grid.ColumnSpan="2"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="false">
                                <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                            <Trigger Property="HasItems" Value="false">
                                <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Width" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinWidth" Value="75"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Height" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinHeight" Value="19"/>
                            </MultiTrigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="Bd" Property="Background" Value="{DynamicResource SelectedBackgroundBrush}"/>
                                <Setter Property="Foreground" Value="{DynamicResource SelectedForegroundBrush}"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="IsSelectionActive" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="Bd" Property="Background" Value="{DynamicResource SelectedBackgroundBrush}"/>
                                <Setter Property="Foreground" Value="{DynamicResource SelectedForegroundBrush}"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <HierarchicalDataTemplate  x:Key="DataItemTemplate" ItemsSource="{Binding Children}" >
            <StackPanel Orientation="Horizontal">
                <ContentPresenter Margin="2,0"
                        Content="{Binding Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>

    </Window.Resources>

        <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="33" />
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="5" HorizontalAlignment="Stretch" Name="groupBox1" VerticalAlignment="Stretch">
            <StackPanel Margin="5" Orientation="Horizontal">
                <RadioButton Content="Depends on" Margin="10,0,20,0" GroupName="Mode" Checked="RadioButton_Checked" Name="rdDependsOn" IsChecked="True" />
                <RadioButton Content="Depends from" Margin="10,0,20,0" GroupName="Mode" Checked="RadioButton_Checked" IsChecked="False" />
            </StackPanel>
            <TextBlock Name="tbReference"></TextBlock>
        </StackPanel>

        <TreeView Grid.Row="1" Margin="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                    x:Name="treeView"
                    ItemsSource="{Binding}"
                    ItemTemplate="{StaticResource DataItemTemplate}">
        </TreeView>
            
        <Button Content="Ok" Grid.Row="2" Height="23" HorizontalAlignment="Right" Name="btnOk" VerticalAlignment="Top" Width="75" Click="btnOk_Click" />
    </Grid>
</ucd:HeaderedDialogWindow>
